import 'package:flutter/material.dart';

class AnimationText extends StatefulWidget {
  final String text;

  const AnimationText({super.key, required this.text});
  @override
  State<StatefulWidget> createState() {
    // TODO: implement createState
    return _AnimationText();
  }
}

class _AnimationText extends State<AnimationText>
    with SingleTickerProviderStateMixin {
  late AnimationController controller1;
  late Animation<Offset> animation1;

  @override
  void initState() {
    super.initState();
    controller1 = AnimationController(
      vsync: this,
      duration: const Duration(seconds: 1),
    );
    // final CurvedAnimation curve =
    //   CurvedAnimation(parent: controller1, curve: Curves.elasticOut);
    //animation1 =
    //  Tween<Offset>(begin: const Offset(0, 0), end: const Offset(0, 60))
    //    .animate(curve);
    controller1.reset();
  }

  @override
  Widget build(BuildContext context) {
    var ret = LayoutBuilder(
      builder: (context, parentContainer) {
        final CurvedAnimation curve =
            CurvedAnimation(parent: controller1, curve: Curves.easeOutCirc);
        animation1 =
            Tween<Offset>(begin: const Offset(0, 0.6), end: const Offset(0, 0))
                .animate(curve);
        controller1.forward(from: 0.0);

        return SlideTransition(
            position: animation1,
            child: Container(
              padding: const EdgeInsets.all(12.0),
              child: Text(
                widget.text,
                //maxLines: 18,
                softWrap: true,
              ),
            ));
      },
    );
    return ret;
  }
}
